﻿/****************************************************************************
Copyright (c) 2014-2015 凌惊雪 微信:Lingjingxue 邮箱:lingjingxue@sina.com QQ:271487457

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/

using ServerBase.Protocol;
using UtilPublic.ServerLoger;
using System;
using System.Collections.Generic;
using UtilLib;
using static ServerBase.Config.Conf;
using ServerPublic.Data;
using ServerGame.Data;
using ServerBase.LunarSocket;

namespace ServerGame.GameObject
{
    /// <summary>
    /// 玩家不需要存档的属性
    /// </summary>
    partial class Player
    {
        #region 玩家链接状态


        //是否链接
        public bool IsConnected => (Session != null && Session.IsConnected);

        //是否已登录
        public bool IsLogin => (IsConnected && Session.Loginded);

        //是否在线
        public bool IsOnline => (DataGame.DictPlayerOnline.ContainsKey(Uid));


        #region 活跃

        //玩家上次活跃时间
        public DateTime 玩家上次活跃时间 = DateTime.Now;
        public void SetActive()
        {
            玩家上次活跃时间 = DateTime.Now;
        }
        //检查是否需要清除缓存
        public bool CheckNeedClearCache()
        {
            return ((DateTime.Now - 玩家上次活跃时间) > TimeSpan.FromHours(1));
        }

        #endregion


        #endregion 玩家链接状态




    }
}